var input = document.getElementById("show-1");
var yearSelect = document.getElementById("yearSelect");
var year="";
//获取当前年份
var nowYear=new Date().getFullYear(); 
//鼠标移入
input.onmouseover = function() {
    yearSelect.style.display = 'block';
    input.getElementsByTagName("input")[0].style.borderRadius="15px 15px 0px 0px";
    input.getElementsByTagName("input")[0].style.borderBottom="0px";
    input.getElementsByTagName("input")[0].style.backgroundColor="#fdfdfd";
}
//鼠标移出
input.onmouseout = function() {
    yearSelect.style.display = 'none';
    input.getElementsByTagName("input")[0].style.borderRadius="15px";
    input.getElementsByTagName("input")[0].style.borderBottom="1px solid #ccc";
    input.getElementsByTagName("input")[0].style.backgroundColor="#eee"
}
//循环打印时间可以通过改变i的值
for(var i=15;i>=0;i--){
    let span=`<span>${nowYear-i}</span>`;
    yearSelect.innerHTML+=span;
}
// 绑定点击事件,点击之后传递值给输入框
let len=yearSelect.querySelectorAll("span").length
for(var i=0;i<len;i++){
    yearSelect.querySelectorAll("span")[i].onclick=function(){
        for(var i=0;i<len;i++){
            yearSelect.querySelectorAll("span")[i].style.fontWeight="normal";
        }
        this.style.fontWeight="bold";
        input.getElementsByTagName("input")[0].value=this.innerHTML;
        year=this.innerHTML;
    }
}

